import unittest
from pyprotobuf.generators.closurelib import ClosureLib
from pyprotobuf.main import parse_and_generate



class ProtorpcTest(unittest.TestCase):
    def setUp(self):
        self.maxDiff = 22065

    def check_expected_output(self, name):
        string = parse_and_generate(open('pyprotobuf/testdata/%s' % name).read(), 'test', ClosureLib)
        self.assertMultiLineEqual(open('pyprotobuf/testdata/%s.js' % name).read(), string)

    def test_nested(self):
        """ Test simple evaluation
        """
        self.check_expected_output('nested.proto')

    def test_defaults(self):
        """ Test enum globals are sorted.
        """
        self.check_expected_output('defaults.proto')


if __name__ == '__main__':
    unittest.main()
